package com.saas.shopping.config;

import com.saas.shopping.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置token拦截器
 * 未启用,注解注释了的
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns 要拦截的接口方法,用**表示全部
        registry.addInterceptor(tokenInterceptor)
                .order(1)
                .addPathPatterns("/goods/**")
                .addPathPatterns("/user/**")
                .addPathPatterns("/order/**")
                .addPathPatterns("/shopCart/**")
                .addPathPatterns("/empl/**")
                .addPathPatterns("/role/**")
                .excludePathPatterns("/**/login")
                .excludePathPatterns("/**/reg");

    }
}